package com.syan.learn.optimization.ch05.memorymodel;

import org.junit.Test;

import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;

public class JavaBeanObjectTest {

	public static void main(String[] args) throws CannotCompileException, NotFoundException, InstantiationException, IllegalAccessException {
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			CtClass c = ClassPool.getDefault().makeClass("Geym" + i);
			c.setSuperclass(ClassPool.getDefault().get("com.syan.learn.optimization.ch05.memorymodel.JavaBeanObject"));
			Class clz = c.toClass();
			JavaBeanObject v = (JavaBeanObject) clz.newInstance();
		}
	}

	@Test
	public void testOneClassLoad()
			throws CannotCompileException, NotFoundException, InstantiationException, IllegalAccessException {
		for (int i = 0; i < Integer.MAX_VALUE; i++) {
			CtClass c = ClassPool.getDefault().makeClass("Geym" + i);
			c.setSuperclass(ClassPool.getDefault().get("com.syan.learn.optimization.ch05.memorymodel.JavaBeanObject"));
			Class clz = c.toClass();
			JavaBeanObject v = (JavaBeanObject) clz.newInstance();
		}
	}
}
